﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace iShoppingDAO
{
    public class LoaiTaiKhoanDAO
    {
        public static  DataTable SelectAllLoai()
        {
            DataTable dt = new DataTable();
            try
            {

                string sql = "SELECT * FROM LoaiTaiKhoan";
                dt = DataProvider.ExecuteQuery(sql);


            }
            catch (Exception ex)
            {
                dt = new DataTable();
            }
            return dt;
        }

        public static DataTable SelectOfMa(string maLoai)
        {
            DataTable dt = new DataTable();
            try
            {

                string sql = "SELECT ChiTietPhanQuyen.MaChiTietPhanQuyen, ChiTietPhanQuyen.MaLoaiTK, PhanQuyen.MaPhanQuyen ,  PhanQuyen.TenQuyen, LoaiTaiKhoan.TenLoaiTK ";
                sql += " FROM ChiTietPhanQuyen INNER JOIN LoaiTaiKhoan ON ChiTietPhanQuyen.MaLoaiTK = LoaiTaiKhoan.MaLoaiTK INNER JOIN PhanQuyen ON ChiTietPhanQuyen.MaPhanQuyen = PhanQuyen.MaPhanQuyen ";
                sql += " WHERE  LoaiTaiKhoan.MaLoaiTK = " + maLoai;
                dt = DataProvider.ExecuteQuery(sql);

            }
            catch (Exception ex)
            {
                dt = new DataTable();
            }
            return dt;
        }
        public static DataTable SelectAll()
        {
            DataTable dt = new DataTable();
            try
            {

                string sql = "SELECT ChiTietPhanQuyen.MaChiTietPhanQuyen, ChiTietPhanQuyen.MaLoaiTK, PhanQuyen.MaPhanQuyen ,  PhanQuyen.TenQuyen, LoaiTaiKhoan.TenLoaiTK ";
                sql += " FROM ChiTietPhanQuyen INNER JOIN LoaiTaiKhoan ON ChiTietPhanQuyen.MaLoaiTK = LoaiTaiKhoan.MaLoaiTK INNER JOIN PhanQuyen ON ChiTietPhanQuyen.MaPhanQuyen = PhanQuyen.MaPhanQuyen ";
                
                dt = DataProvider.ExecuteQuery(sql);

            }
            catch (Exception ex)
            {
                dt = new DataTable();
            }
            return dt;
        }

    }
}
